package methodEmbedding.Standing_Ovation.S.LYD214;


import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class StandingOvation {

	public static void main(String[] args) {
		try {
			Scanner sc = new Scanner(new File ("C:/Nandan/GoogleCodeJam/2015_Qualification/resources/StandingOvation/A-small.in"));
			int T = sc.nextInt();
			
			for (int t = 1; t <= T; t++) {
				int sMax = sc.nextInt();
				//String str = "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999";//sc.next();
				String str = sc.next();
				char[] s =  str.toCharArray();
				
				int length = s.length;
				
				int totalAudience = 0;
				int minAudience = 0;
				for(int i = 0; i < length ; i++){
					int si = Integer.parseInt(s[i]+"");
					int temp = 0;
					if( totalAudience < i ){
						temp = i - totalAudience;
					}
					totalAudience = totalAudience + si + temp;
					minAudience = minAudience + temp;
				}
				
				System.out.println("Case #"+t+": "+minAudience);
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
